import { ReactNode } from 'react';
import { Navigate } from 'react-router-dom';
import { useAppSelector } from '../../store/hooks';

export const RequireAuth = ({ children }: { children: ReactNode }) => {
	const {token} = useAppSelector(state => state.authorization.user);

	if (!token) {
		return <Navigate to={'/'} replace />;
	}
	return children;
};
